package com.magicsoft.app.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.boyuan.huijiaoyu.R;
import com.magicsoft.app.entity.TransferCZYRecordEntity;

public class TransferCZYRecordAdapter extends BaseAdapter{
	private LayoutInflater inflater;
	private List<TransferCZYRecordEntity> data;
	private Context context;
	
	public TransferCZYRecordAdapter(Context context, List<TransferCZYRecordEntity> data) {
		inflater = LayoutInflater.from(context);
		this.context = context;
		this.data = data;
	}

	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.list_transfer_czy, null);
			holder.tvTime = (TextView) convertView.findViewById(R.id.tv_time);
			holder.tvDate = (TextView) convertView.findViewById(R.id.tv_date);
			holder.tvTitle = (TextView) convertView.findViewById(R.id.tv_title);
			holder.tvAmount = (TextView) convertView.findViewById(R.id.tv_amount);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		TransferCZYRecordEntity entity = data.get(position);
		String time = entity.getTime();
		String date = entity.getDate();
		String title = entity.getTitle();
		String amount = entity.getAmount();
		
		holder.tvTime.setText(time);
		holder.tvDate.setText(date);
		holder.tvTitle.setText(title);
		holder.tvAmount.setText(amount);
		
		return convertView;
	}
	
	private final class ViewHolder {
		TextView tvTime;
		TextView tvDate;
		TextView tvTitle;
		TextView tvAmount;
	}
}
